home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 August - Disc 1 / PCNET_CD_2006_08_1.iso / shareware / AutoHotkey104407_Install.exe / Extras / Run this to install syntax and clip files for jEdit.ahk < prev    next >
Encoding:
Text File  |  2005-03-27  |  5.1 KB  |  144 lines

  1. ;;; ============================================================================
  2. ;;;   FILENAME: Run this to install syntax and clip files for ahk.xml
  3. ;;; ============================================================================
  4. ;;;   Install AutoHotkey syntax highlighting and clip files in jEdit
  5. ;;; ============================================================================
  6.  
  7. ;;;   AUTHOR:  Andreas Gleichmann
  8. ;;;   VERSION: 1.0.0, 26.05.2005
  9. ;;;       Based on installscript 'Run this to install syntax and clip files for PSPad.ahk' from Scott Greenberg
  10. ;;;
  11. ;;; ============================================================================
  12. ;;;   HISTORY:
  13. ;;; ============================================================================
  14. ;;;   DISCLAIMER:
  15. ;;;   Permission to use, copy, modify, and distribute this software 
  16. ;;;   for any purpose and without fee is hereby granted, provided 
  17. ;;;   that the above copyright notice appears in all copies and that 
  18. ;;;   both that copyright notice and this permission notice appear in 
  19. ;;;   all supporting documentation.
  20. ;;;
  21. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED
  22. ;;;   WARRANTY.  ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR
  23. ;;;   PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.
  24. ;;; ============================================================================
  25.  
  26. ;;; Directives, required by this script (do not change)
  27. #SingleInstance force
  28. #EscapeChar \
  29. SetBatchLines,-1
  30. ScriptTitle = AutoHotkey jEdit Setup
  31. ;;;  Used to aid in bugging script
  32. ;; debugging on  = 1
  33. ;; debugging off = 0
  34. bDebug = 0
  35. IfNotEqual, bDebug, 1
  36. {
  37.     MsgBox, 4, %ScriptTitle%, This will install file for jEdit to handle AutoHotkey scripts.\nWould you like to continue with the install?
  38.     IfMsgBox, No
  39.         ExitApp
  40. }
  41.  
  42.  
  43. jEditTitleName=jEdit - 
  44. jEditUserPath=%USERPROFILE%\\.jedit
  45. jEditCatalogPath=%jEditUserPath%\\modes
  46. jEditCatalogFile=catalog
  47. jEditSyntaxFile=ahk.xml
  48. jEditCatalogPathFile=%jEditCatalogPath%\\%jEditCatalogFile%
  49. ;;; Allow user to select from dialog, when unable to locate PSPad
  50. IfNotExist, %jEditCatalogPath%
  51.     FileSelectFile, jEditCatalogPathFile, 1, %jEditCatalogPath%\\%jEditCatalogFile%, Select the jEdit catalog File.
  52. SplitPath, jEditCatalogPathFile, jEditCatalogFile, jEditCatalogPath
  53. IfEqual, bDebug, 1
  54.     MsgBox, 0, %ScriptTitle%, jEditCatalogPathFile:%jEditCatalogPathFile%, jEditCatalogFile:%jEditCatalogFile%, jEditCatalogPath:%jEditCatalogPath%
  55. ;;; Get AutoHotkey exe path from registry.
  56. RegRead, AHKExe, HKLM, SOFTWARE\\AutoHotkey, InstallDir
  57. AHKExe = %AHKExe%\\AutoHotkey.exe
  58. ;;; Allow user to select from dialog, when unable to locate AutoHotkey
  59. IfNotExist, %AHKExe%
  60.     FileSelectFile, AHKExe, 1, %A_ProgramFiles%\\AutoHotkey\\AutoHotkey.exe, Select the AutoHotkey executable., Executable (*.exe)
  61. IfNotExist, %AHKExe%
  62.     Goto, DownloadAHK
  63.  
  64. ;;; Copy files to jEdit dir
  65. file = %A_WORKINGDIR%\\%jEditSyntaxFile%
  66. IfExist, %file%
  67. {
  68.     ; Make backup of old file if it exists and if there isn't already a backup file (this relies
  69.     ; on it failing to do anything otherwise):
  70.     FileMove, %jEditCatalogPath%\\%jEditSyntaxFile%, %jEditCatalogPath%\\%jEditSyntaxFile%.backup
  71.     FileCopy, %file%, %jEditCatalogPath%, 1
  72. }
  73.  
  74. ;;; add the syntax file to the jEdit catalog
  75. ;;search <MODE NAME="ahk" FILE="ahk.xml" FILE_NAME_GLOB="*.{ahk}"/> in catalog file
  76. Found=0
  77. IfEqual, bDebug, 1
  78.     MsgBox, 0, %ScriptTitle%, Search %jEditCatalogPathFile%.
  79. Loop, Read, %jEditCatalogPathFile%
  80. {
  81.     ifInString, A_LoopReadLine, NAME="ahk"
  82.     {
  83.     IfEqual, bDebug, 1
  84.         MsgBox, 0, %ScriptTitle%, AHK Syntaxfile already exist in the catalog file. Nothing to do
  85.     Found=1
  86.     break
  87.     }
  88. }
  89.  
  90. if Found=0
  91. {
  92.     ;;; Close jEdit
  93.     IfWinExist, %jEditTitleName%
  94.     {
  95.     If bDebug <> 1
  96.         WinClose ; use the window found above
  97.     }
  98.     
  99.    jEditCatalogPathFile_new=%jEditCatalogPathFile%_new
  100.     IfEqual, bDebug, 1
  101.         MsgBox, 0, %ScriptTitle%, Add AHK Syntaxfile to the catalog file %jEditCatalogPathFile_new%.
  102.  
  103.     IfExist, %jEditCatalogPathFile_new%, FileDelete, %jEditCatalogPathFile_new%
  104.     
  105.     Loop, Read, %jEditCatalogPathFile%, %jEditCatalogPathFile_new% 
  106.     {
  107.     ifInString, A_LoopReadLine, </MODES>
  108.     {
  109.         IfEqual, bDebug, 1
  110.             MsgBox, 0, %ScriptTitle%, Add definition line to the catalog file.
  111.         FileAppend, <MODE NAME="ahk" FILE="ahk.xml" FILE_NAME_GLOB="*.{ahk}"/>\n
  112.     }
  113.     FileAppend, %A_LoopReadLine%\n
  114.     }
  115.     IfExist, %jEditCatalogPathFile%.backup, FileDelete, %jEditCatalogPathFile%.backup
  116.     FileMove, %jEditCatalogPathFile%, %jEditCatalogPathFile%.backup
  117.     FileMove, %jEditCatalogPathFile_new%, %jEditCatalogPathFile%
  118. }
  119.  
  120. ExitApp
  121.  
  122.  
  123. DownloadAHK:
  124. url = http://www.autohotkey.com/
  125. valSet := 0
  126. Gui, Font, norm
  127. Gui, Add, Text,, We sure AutoHotkey is installed but we are unable to find it. Unable to continue.
  128. Gui, Font, underline
  129. Gui, Add, Text, cBlue gOpenLink, Click here to Download AutoHotkey.
  130. Gui, Font, norm
  131. Gui, Add, Button, Default, &OK
  132. Gui, Show, AutoSize, ScriptTitle
  133. Loop
  134. {
  135.     if valSet
  136.         break
  137. }
  138. ExitApp -1
  139.  
  140. OpenLink: 
  141. Run, %url%
  142. ExitApp -1
  143. return
  144.